package com.huawei.hms.support.api.hwid;

import android.content.Intent;
import android.os.Bundle;
import com.huawei.hms.core.aidl.IMessageEntity;
import com.huawei.hms.support.api.PendingResultImpl;
import com.huawei.hms.support.api.client.ApiClient;
import com.huawei.hms.support.api.client.Result;
import com.huawei.hms.support.api.client.Status;
import com.huawei.hms.support.api.entity.hwid.HwIDConstant.RETKEY;
import com.huawei.hms.support.api.entity.hwid.QueryShippingAddressResp;
import com.huawei.hms.support.api.entity.hwid.ShippingAddressParcelable;
import com.huawei.hms.support.log.HMSLog;
import java.util.ArrayList;

class HuaweiIdApiImpl$b extends PendingResultImpl<AddressResult, QueryShippingAddressResp> {
    public /* synthetic */ Result onComplete(IMessageEntity iMessageEntity) {
        return a((QueryShippingAddressResp) iMessageEntity);
    }

    public HuaweiIdApiImpl$b(ApiClient apiClient, String str, IMessageEntity iMessageEntity) {
        super(apiClient, str, iMessageEntity);
    }

    public AddressResult a(QueryShippingAddressResp queryShippingAddressResp) {
        if (queryShippingAddressResp == null) {
            HMSLog.e("HuaweiIdApiImpl", "queryShippingAddressResp is invalid.");
            return new AddressResult(new Status(2005));
        }
        ArrayList shippingAddressInfoList;
        HMSLog.i("HuaweiIdApiImpl", "QueryShippingAddress.ResultCode:" + queryShippingAddressResp.getRetCode());
        int retCode = queryShippingAddressResp.getRetCode();
        AddressResult addressResult = new AddressResult();
        addressResult.setStatus(queryShippingAddressResp.getCommonStatus());
        if (retCode == 0) {
            Intent data = queryShippingAddressResp.getData();
            if (data != null) {
                Bundle extras = data.getExtras();
                if (extras != null) {
                    extras.setClassLoader(getClass().getClassLoader());
                    ShippingAddressParcelable shippingAddressParcelable = (ShippingAddressParcelable) extras.getParcelable(RETKEY.SHIPPING_ADDRESS);
                    if (shippingAddressParcelable != null) {
                        shippingAddressInfoList = shippingAddressParcelable.getShippingAddressInfoList();
                    } else {
                        HMSLog.e("HuaweiIdApiImpl", "shippingAddressParcelable is null");
                        shippingAddressInfoList = null;
                    }
                }
            }
            HMSLog.e("HuaweiIdApiImpl", "data or bundle is null");
            shippingAddressInfoList = null;
        } else {
            HMSLog.e("HuaweiIdApiImpl", "retCode is not ok");
            shippingAddressInfoList = null;
        }
        addressResult.setShippingAddressInfoList(shippingAddressInfoList);
        return addressResult;
    }
}
